1 package controllers
.actions
;
3 import javax
.swing
.undo
.AbstractUndoableEdit
;
5 import models
.GraphEdge
;
6 import models
.GraphVertex
;
9 public class DeleteNode
extends AbstractUndoableEdit
{
10 private static final long serialVersionUID
= -7929100929760152271L;
11 private GraphVertex o
;
12 private SelectionController selectionController
;
14 private GraphEdge
[] affectedEdges
;
16 public DeleteNode(SelectionController selectionController
)
18 this.selectionController
= selectionController
;
19 this.o
= selectionController
.getSelectedVertex();
23 private void removeAffectedEdges()
25 selectionController
.getModel().removeEdge(affectedEdges
);
28 private void addAffectedEdges()
30 selectionController
.getModel().addEdge(affectedEdges
);
33 private void getAffectedEdges(){
34 GraphEdge
[] arr
= selectionController
.getModel().getEdges();
36 for(int i
=0; i
< arr
.length
; i
++)
40 affectedEdges
= new GraphEdge
[count
];
41 for(int i
=0; i
< arr
.length
; i
++)
43 affectedEdges
[count
++] = arr
[i
];
50 removeAffectedEdges();
51 selectionController
.removeSelected();
52 selectionController
.getModel().removeGraph(o
);
58 selectionController
.getModel().addGraph(o
);
59 selectionController
.setSelected(o
);